package com.inspur.demo.core.result;

import lombok.Data;

/**
 * @ClassName Result
 * @Description TODO
 * @Company inspur
 * @Author Mark.Zhang
 * @Date 2019/5/17 14:21
 * @Version 1.0 
 */
@Data
public class Result<T> {
    public int code;
    public String msg;
    public T data;

    public Result() {
    }

    public Result(T data) {
        this.data = data;
    }

    public Result(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 成功时候的调用
     */
    public static <T> Result<T> success(T data) {
        return new Result<T>(data);
    }

    /**
     * 失败时候的调用
     */
    public static <T> Result<T> error(int code, String msg) {
        return new Result<T>(code, msg);
    }

}
